@echo off
chcp 65001 >nul
echo ========================================
echo Fall Data 批量清理和获取依赖脚本
echo ========================================
echo.

set MODULES=fall_data_base fall_data_gen fall_data_main

for %%m in (%MODULES%) do (
    echo ========================================
    echo 处理模块: %%m
    echo ========================================
    
    if exist "%%m" (
        cd %%m
        
        echo [%%m] 执行 flutter clean...
        call flutter clean
        if errorlevel 1 (
            echo [错误] %%m 执行 flutter clean 失败
            cd ..
            goto :error
        )
        echo [%%m] flutter clean 完成
        echo.
        
        echo [%%m] 执行 flutter pub get...
        call flutter pub get
        if errorlevel 1 (
            echo [错误] %%m 执行 flutter pub get 失败
            cd ..
            goto :error
        )
        echo [%%m] flutter pub get 完成
        echo.
        
        cd ..
    ) else (
        echo [警告] 模块目录不存在: %%m
        echo.
    )
)

echo ========================================
echo 所有模块处理完成！
echo ========================================
pause
exit /b 0

:error
echo.
echo ========================================
echo 执行过程中出现错误，已终止
echo ========================================
pause
exit /b 1
